package com.puman.beautyfarmcounselor.ui.home.adpter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.puman.beautyfarmcounselor.R;
import com.puman.beautyfarmcounselor.ui.customer.model.SurplusRecord;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Curry on 2015/6/12.
 */
public class SurplusListAdapter extends RecyclerView.Adapter<SurplusListAdapter.ViewHolder> {

    private List<SurplusRecord> surplusRecords = new ArrayList<SurplusRecord>();
    private Context context;

    public SurplusListAdapter(Context context, List<SurplusRecord> surplusRecords) {
        this.context = context;
        this.surplusRecords = surplusRecords;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        private final TextView time;
        private final TextView content;
        public ViewHolder(View v) {
            super(v);
            time = (TextView) v.findViewById(R.id.surplus_rcord_datetime);
            content = (TextView) v.findViewById(R.id.surplus_record_content);
        }

        public TextView getTime() {
            return time;
        }

        public TextView getContent() {
            return content;
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.surplus_recordlist_item, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.getContent().setText(surplusRecords.get(position).getProduct_name());
        holder.getTime().setText(surplusRecords.get(position).getEnd_date());
    }

    @Override
    public int getItemCount() {
        return surplusRecords.size();
    }


}
